import React,{Component} from 'react'
import {Redirect,Switch,Route} from 'react-router-dom'
import { Layout } from 'antd'

import LeftNav from'../../components/left-nav'
import Header from '../../components/header'
import memoryUtil from '../../utils/memoryUtil'
import Category from '../category'
import Bar from '../charts/bar'
import Line from '../charts/line'
import Pie from '../charts/pie'
import Home from '../home'
import Product from '../product'
import Role from '../role'
import User from '../user'

const {Footer, Sider, Content } = Layout;


/*
*  后台管理路由组件
* */
export default class  Admin extends Component{

    render(){
        const user=memoryUtil.user;
        if (!user||!user.id) {
          return <Redirect to='/login'/>
        }
        return (
            <Layout style={{height:'100%'}}>
                <Sider>
                    <LeftNav/>
                </Sider>
                <Layout>
                    <Header>Header</Header>
                    <Content style={{backgroundColor:'#fff'}}>
                        <Switch>
                            <Route path='/home' component={Home}/>
                            <Route path='/category' component={Category}/>
                            <Route path='/product' component={Product}/>
                            <Route path='/role' component={Role}/>
                            <Route path='/user' component={User}/>
                            <Route path='/bar' component={Bar}/>
                            <Route path='/line' component={Line}/>
                            <Route path='/pie' component={Pie}/>
                            <Redirect path='/home'/>
                        </Switch>
                    </Content>
                    <Footer style={{textAlign:'center',color:'#cccccc'}}>推荐使用Google浏览器</Footer>
                </Layout>
            </Layout>
        )
    }
}